<?php
if (file_exists('Fichiers/Description_auto.xml')) {
    $xml_description_auto = simplexml_load_file('Fichiers/Description_auto.xml');
    $_SESSION['xml_description_auto'] = $xml_description_auto;
} else {
    exit('Echec lors de l\'ouverture du fichier xml.');
}
$nb = $_POST["CodeElt"];
$nb = intval($nb);
$marque = $xml_description_auto->ROW[$nb]->marque;
?>
<select name='Lst_modele' id='Lst_modele'>
    <option value='-1'>Choisir un modele </option>
    <?php
    for ($i = 0; $i < count($xml_description_auto->ROW); $i++) {
        if (str_replace(" ", "", $xml_description_auto->ROW[$i]->marque) == str_replace(" ", "", $marque)) {
            if ($i > 1) {
                if (str_replace(" ", "",$xml_description_auto->ROW[$i]->modele) != str_replace(" ", "",$xml_description_auto->ROW[($i + 1)]->modele)) {
                    ?>
                    <option value=<?php echo $i; ?>><?php echo $xml_description_auto->ROW[$i]->modele; ?></option>
                    <?php
                }
            } else {
                ?>
                <option value=<?php echo $i; ?>><?php echo $xml_description_auto->ROW[$i]->modele; ?></option>
                <?php
            }
        }
    }
    ?>
</select>